package com.dreamchaser.familydevice.dao;

import com.dreamchaser.familydevice.domain.dto.DeviceExpression;
import com.dreamchaser.familydevice.po.Component;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author shajie
 * @since 2020-08-16
 */
public interface ComponentMapper extends BaseMapper<Component> {

    @Select("select t2.id deviceCode,t1.id mainComId,t1.com_code mainComCode,t3.status_code statusCode,t3.`condition` expression,t3.internal_func internalFunc from component t1\n" +
            "join device t2 on t2.main_com_id=t1.id\n" +
            "join com_status t3 on t3.com_id=t2.main_com_id")
    List<DeviceExpression> selectListExpression();

    @Select("select t1.* from component t1 \n" +
            "join device t2 on t1.id=t2.main_com_id and t2.id=#{deviceCode}")
    Component selectByDeviceId(int deviceCode);
}
